package com.hy.singleton;

/**
 * Created With IntelliJ IDEA.
 * Descriptions:饿汉式
 * <p>
 * User:Mr.Du
 * Date:2024/8/8
 * Time:17:34
 */
public class EagerSingleton {

    // 类加载时就初始化实例
    public static EagerSingleton instance = new EagerSingleton();

    // 私有构造方法，防止外部实例化
    private EagerSingleton() {}

    // 公有静态方法，返回唯一实例
    public static EagerSingleton getEagerSingleton() {
        return instance;
    }

}
